
#include <iostream>
#include <csignal>

volatile int gflag = 0;

void changedata(int signo)
{
    std::cout << "get a signo: " << signo << ", change gflag 0 -> 1..." << std::endl;
    gflag = 1;
}


int main()
{

    signal(2, changedata);

    while (!gflag); // while 循环体里不能有代码 

    std::cout << "process quit normal" << std::endl;

    return 0;
 }
